home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1999 November / SGI IRIX 6.5 Applications 1999 November.iso / dev / insight_dev.idb / usr / share / Insight / bin / xref.awk.input.z / xref.awk.input
Encoding:
Text File  |  1998-10-28  |  1.3 KB  |  84 lines

  1. #Assumptions:
  2. # 1. 2 input files are passed ( xref, xref targets)
  3. # 2. NOLINES is passed as a parameter which contains the no. of lines in first input file
  4. BEGIN { }
  5. {
  6.  
  7.     if ( NR <= NOLINES ) {
  8.         nf1 = NR  ;
  9.         a[NR] = $1 ;
  10.     }
  11.     else {
  12.         nf2 = NR  ;
  13.         b[NR-NOLINES] = $1 ;
  14.  
  15.     }
  16. }
  17. END {
  18.     nf2 = nf2 - nf1 ;
  19. #    print nf1 nf2
  20. #    for( ind=1 ; ind <= nf1 ; ind ++ ) print a[ind] ;
  21. #    for( ind=1 ; ind <= nf2 ; ind ++ ) print b[ind] ;
  22. # Values  in a[] and b[] are in ascending order
  23.     
  24.     if ( XREFNEEDED == 1 ) {
  25.     k = 0;
  26.     total = 0;
  27.  
  28.     for (i = 1; i <= nf1 ; i ++) {
  29.       for(j = 1 ; j <= nf2 ; j++ ) {
  30.         if (a[i] == b[j] ) 
  31.             break ;
  32.         else if (a[i] > b[j] )
  33.             continue ;
  34.         else {
  35.             c[++k] = a[i] ;
  36.             total = k ;
  37.             break ;
  38.         }
  39.       }
  40.     }
  41.  
  42. #    printf("Reference IDs outside this book:");
  43.     if ( total > 0 )
  44.         for ( k =1 ; k <= total ; k++)
  45.             printf("%d ",c[k]);
  46. #    else 
  47. #        printf("None");
  48. #    printf("\n");
  49.  
  50.     }
  51.  
  52.     else {
  53.  
  54. # Inter change a[]'s and b[]'s and do the same
  55.  
  56.     k = 0;
  57.     total = 0;
  58.  
  59.  
  60.     for (j = 1; j <= nf2 ; j ++) {
  61.       for(i = 1 ; i <= nf1 ; i++ ) {
  62.         if (a[i] == b[j] ) 
  63.             break ;
  64.         else if (a[i] < b[j] )
  65.             continue ;
  66.         else {
  67.             c[++k] = b[j] ;
  68.             total = k ;
  69.             break ;
  70.         }
  71.       }
  72.     }
  73.  
  74. #    printf("Target IDs from outside this book:");
  75.     if ( total > 0 )
  76.         for ( k =1 ; k <= total ; k++)
  77.             printf("%d ",c[k]);
  78. #    else 
  79. #        printf("None");
  80. #    printf("\n");
  81.  
  82.     }
  83. }
  84.